package com.yanfan.attach.controller;

import com.yanfan.attach.domain.DeviceDetail;
import com.yanfan.attach.service.IDeviceDetailService;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.domain.entity.SysDictData;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.system.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/attach-common")
public class MyCommonController extends BaseController {

    @Autowired
    private ISysDictDataService sysDictDataService;
    @Autowired
    private IDeviceDetailService deviceDetailService;

    @GetMapping("/dicts")
    public AjaxResult dicts(SysDictData dict) {
        return AjaxResult.success(sysDictDataService.selectDictDataList(dict));
    }

    @GetMapping("/device-short-all")
    public TableDataInfo deviceShortAll(DeviceDetail device) {
        if (null == device.getDeptId()) {
            device.setDeptId(getLoginUser().getDeptId());
        }
        return getDataTable(deviceDetailService.selectAllDeviceShortList(device));
    }
}
